<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>PaintHooks</title>
</head>

<body text="#FFFFFF" bgcolor="#000000" style="font-family: Verdana; font-size: 10pt" link="#00FFFF" vlink="#00FFFF" alink="#00FFFF">

<p><font size="3"><b>Scenario PaintHooks</b></font></p>
<p>PaintHooks provide a way for you to render your own custom graphics directly 
to the game map during play.&nbsp; The PaintHooks provide you access to the .NET 
Graphics object that represents the visible portion of the game map.&nbsp; You 
can use any .NET graphics calls to draw to the Graphics object.</p>
<p>There are two PaintHooks available, one happens after the background elements 
are rendered, but before the StarShip, StarSystem, and all of the other sprites 
in the game.&nbsp; The second happens after all of the sprites have been 
rendered.</p>
<p>To hook into the rendering of the map, override one or both of these methods 
in your Scenario class's code:</p>
<font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> <b>void</b></font><font SIZE="2"> 
PaintHookBeforeSpriteRender(</font><font SIZE="2" COLOR="#00FFFF">Graphics</font><font SIZE="2"> 
g, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
offsetx, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
offsety, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
width, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
height)</p>
</font><font SIZE="2" COLOR="#00FFFF"><b>
<p>public</b> <b>virtual</b> <b>void</b></font><font SIZE="2"> 
PaintHookAfterSpriteRender(</font><font SIZE="2" COLOR="#00FFFF">Graphics</font><font SIZE="2"> 
g, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
offsetx, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
offsety, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
width, </font><font SIZE="2" COLOR="#00FFFF"><b>int</b></font><font SIZE="2"> 
height)</p>
</font>
<p>The Graphics &quot;g&quot; object provides the actual .NET Graphics object for the game 
map.&nbsp; As such, you can use any .NET Graphics method to render to the 
object.</p>
<p>Offsetx and offsety provide the x/y offsets, or how much the map has been 
scrolled.&nbsp; When determing the location to render information on the map, 
you should generally subtract these offset amounts.</p>
<p>Each square on the SV map is 30x30 pixels in size.&nbsp; With this in mind, 
you can calculate the proper location within the Graphics object that 
corresponds to player 1's Capital like this:</p>
<p>StarSystem capital = Game.Players[0].Capital;<br>
int x = capital.x * 30 - offsetx + 15;<br>
int y = capital.y * 30 - offsety + 15;</p>
<p>Note that we add 15 to each value so that the result is &quot;centered&quot; on the 
StarSystem's location on the map.</p>
<p>The width and height parameters provide the current physical size of the 
visible map.&nbsp; You can use this information to determine if what you want to 
draw is outside of the visible map area, avoiding unnecessary drawing calls.</p>
<p><font color="#FFFF00"><b>Example</b></font></p>
<p>See the CollectTheScientists.cs Scenario for an example of a PaintHook.&nbsp; 
It renders the current player's &quot;Safe Zone&quot;, which is an area next to their 
Capital, as a shaded red box.&nbsp; It also displays some status information in 
the upper left corner of the map so players can know how many of the Scientists 
have been collected.</p>

</body>

</html>